package levels;

import lobster.games.studios.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager.LayoutParams;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
 

public class Level1 extends Activity{

	private Thread splashTread;
	private ImageView windowImage;
	private TextView levelText;
	private Button icon2;
	private RelativeLayout screenLayout, windowLayout;
	private LinearLayout itemsLayout;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.level);
		getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON);


		screenLayout = (RelativeLayout)findViewById(R.id.gamelayout);
		windowLayout = (RelativeLayout)findViewById(R.id.windowlayout);
		itemsLayout = (LinearLayout)findViewById(R.id.linearlayout);


		windowImage = new ImageView(this);
		icon2 = new Button(this);
		
		windowImage.setImageResource(R.drawable.window);

		windowLayout.addView(windowImage);
		icon2 = (Button)findViewById(R.id.button2);
		icon2.setBackgroundResource(R.drawable.ic_launcher);
		
		levelText = new TextView(this);
		levelText = (TextView)findViewById(R.id.leveltext);
		levelText.setText("Level 1");
		
				


		windowImage.setOnClickListener(new OnClickListener() {

			//@Override
			public void onClick(View v) {
				windowImage.invalidate();
				windowImage.setImageResource(R.drawable.openwindow);

				splashTread = new Thread() {
					@Override
					public void run() {
						try {
							synchronized(this){
								//wait 1 sec
								wait(1000);
							}

						} catch(InterruptedException e) {}
						finally {
							//start a new activity
							Intent intent = new Intent(getApplicationContext(), Level2.class);
							startActivity(intent);
							//  stop();
						}
					}
				};
				splashTread.start();
			}
		});
	}
}
